<?php

class DicasController extends Site_Controller_Action
{

    public function init()
    {
        
    } 

    public function indexAction()
    {
        Zend_Loader::loadClass('dominio','library');
        
        $query = 'SELECT SQL_CACHE * FROM PAGINASSITE WHERE PAG_MODULO = "'.$this->_controller.'" and CTS_ID = '.$this->_segmento->CTS_ID;
        $row = $this->db->fetchRow($query);
        $this->view->result = $row;
        
        //$dic = new Sistema_Model_DbTable_Dicas();
        //$dic = $dic->fetchAll('CTS_ID like "%'.$this->_segmento->CTS_ID.'%" and DIC_STA = 1');
        $where = 'CTS_ID like "%'.$this->_segmento->CTS_ID.'%" and DIC_STA = 1';
        
        $cat = $this->_getParam('cat', 0);
        if($cat > 0) $where .= ' AND CTD_ID = '.$cat;
        
        //$dic = $dic->fetchAll($dic->select()->where($where)->order('DIC_ORD ASC'));
        $query = 'SELECT SQL_CACHE * FROM DICAS WHERE '.$where.' ORDER BY DIC_ORD ASC';
        $dic = $this->db->fetchAll($query);
        $this->view->dic = $dic;
        
        //$cat = new Sistema_Model_DbTable_Categoriadicas();
        //$cat = $cat->fetchAll('CTD_STA = 1');
        $query = 'SELECT SQL_CACHE * FROM CATEGORIA_DICAS WHERE CTD_STA = 1';
        $cat = $this->db->fetchAll($query);
        $this->view->cat = $cat;
        
        $this->view->dir = dominio::getdirGaleria('dicas'); 
    }


}

